// Copyright (c) 2018 Muhammad M. Imtiaz

// This Work is subject to the terms of the Universal Permissive License,
// Version 1.0. If a copy of the licence was not distributed with this Work,
// you can obtain one at <https://oss.oracle.com/licenses/upl/>.

// Muhammad M. Imtiaz
// Calculates and categorises BMI of a person based on data they provide about themselves.
// Wednesday 17 October 2018

public class BMI {
    public static void main(String[] args) {
        java.util.Scanner input = new java.util.Scanner(System.in);
	String name;
	String gender;
	String[] height;
	int age;
	int heightInches;
	int weightPounds;
	double heightMetres;
	double weightKg;
	double BMI;

	System.out.print("Enter your name (first last): ");
	name = input.nextLine();
	System.out.print("Enter your weight in pounds: ");
	weightPounds = input.nextInt();
	System.out.print("Enter your height in feet and inches: ");
	height = input.nextLine().split(" ");

	heightInches = Integer.parseInt(height[0]) * 12 + Integer.parseInt(height[1]);

	heightMetres = heightInches * 0.0254;
        weightKg = weightPounds * 0.45359237;

	BMI = weightKg / (heightMetres * heightMetres);

	System.out.println("Name: " + name);
	System.out.println("Height (m): " + heightMetres);
	System.out.println("Weight (kg): " + weightKg);
	System.out.println("BMI: " + BMI);
	System.out.print("Category: ");

	if(BMI >= 30)
	    System.out.println("Obese");
	else if(BMI >= 25)
	    System.out.println("Overweight");
	else if(BMI < 18.5)
	    System.out.println("Underweight");
	else
	    System.out.println("Normal");
    }
}
